//引入express
var express = require('express')
//实例化express
var app = express()
//使用app.use()中间件以及express.static()中间件
app.use(express.static('static'));
//设置处理post请求参数的中间件
app.use(express.json())
app.use(express.urlencoded({ extended: false }))

//返回给客户端的数据
// var arr = [
//     { "id": 1, "mail": "cbkkhsbf@sina.com", "name": "李丽", "phone": 15844118213, "ingroup": "编辑组", "ismanager": true, "status": true },
//     { "id": 2, "mail": "cbdghsbf@sina.com", "name": "刘璇", "phone": 16344118213, "ingroup": "美工组", "ismanager": false, "status": true },
//     { "id": 3, "mail": "cbdgshrf@sina.com", "name": "张利", "phone": 17444118213, "ingroup": "编辑组", "ismanager": true, "status": false },
//     { "id": 4, "mail": "cbdghsbf@sina.com", "name": "吴优", "phone": 15844565613, "ingroup": "审核组", "ismanager": true, "status": false },
//     { "id": 5, "mail": "cbshrsbf@sina.com", "name": "李宇", "phone": 15844155667, "ingroup": "美工组", "ismanager": false, "status": true },
//     { "id": 6, "mail": "cbdghshr@sina.com", "name": "王丽", "phone": 13258113456, "ingroup": "编辑组", "ismanager": false, "status": true },
//     { "id": 7, "mail": "cbdghsbf@sina.com", "name": "周丽", "phone": 13258118213, "ingroup": "编辑组", "ismanager": true, "status": false },
//     { "id": 8, "mail": "shrghsbf@sina.com", "name": "孙文文", "phone": 13234568213, "ingroup": "审核组", "ismanager": false, "status": true },
//     { "id": 9, "mail": "cbdghsbf@sina.com", "name": "何维", "phone": 13278958213, "ingroup": "编辑组", "ismanager": true, "status": false }
// ]

//设置接口

//导入拆分的子路由
var userRouter = require('./router/userRouter')

//注册子路由, 凡是 '/user' 开头的请求, 都找userRouter这个子路由来提供服务
app.use('/user',userRouter)
//设置监听
app.listen(8888, () => {
    console.log('服务端运行在:http://localhost:8888');
})